﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AP.Framework.Infrastructure.Repositories.IRepositories;
using AP.Framework.Infrastructure.Entities;
namespace AP.Web.Controllers
{
    public class ProductController : Controller
    {
        IProduct _product;
        public ProductController(IProduct product)
        {
            _product = product;
        }
        public ActionResult Index(int? productCategoryId)
        {
            IEnumerable<cms_Product> productList = null;
            if (productCategoryId > 0)
            {
                productList = _product.GetAll().Where(p => p.ProductCategoryId == productCategoryId).OrderBy(p => p.ModifyBy).ToList();
            }
            else
            {
                productList = _product.GetAll().OrderBy(p => p.ModifyBy).ToList();
            }
            return View(productList);
        }
        public ActionResult ViewDetails(int? productId)
        {
            cms_Product model = _product.GetAll().Where(p => p.ID == productId).FirstOrDefault();
            return View(model);

        }
    }
}
